const express = require('express');
const router = express.Router();

const User = require('../models/user');

/* GET home page. */
router.get('/', function (req, res, next) {
    const user = req.user;
    if (user) {
        User.findOne({where:{name:req.user.name}}).then(u => {
            req.user.validate = u.checkValidate();
            res.render('index', {user: req.user});
        })
    }else{
        res.render('index',{user:undefined});
    }
});

module.exports = router;
